package com.qs.education.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.qs.education.bean.api.PageBean;
import com.qs.education.bean.entity.EducationQuestion;
import com.qs.education.bean.service.BaseService;
import com.qs.education.service.IQuestionAPIService;

@Service
public class QuestionAPIServiceImpl extends BaseService implements IQuestionAPIService {

	@Override
	public PageBean getQuestionList(EducationQuestion educationQuestion, Integer currentPage, Integer pageSize) {
		
		int recordCount = iEducationQuestionDao.getQuestionCount(educationQuestion);
		List<EducationQuestion> list = iEducationQuestionDao.getQuestionList(educationQuestion,currentPage,pageSize);
		for (EducationQuestion question :list ) {
			question.setHomeWorkQuestionList(null);
		}
		PageBean pageBean = new PageBean(currentPage, pageSize, recordCount, list);
		
		return pageBean;
	}

	@Override
	@Transactional
	public Boolean deleteQuestionById(Integer id) {
		
		return iEducationQuestionDao.delete(id.longValue(), EducationQuestion.class);
	}

}
